<template>
<view class="page">
	<!-- 余额流水 -->
	<view v-if="isLogin" class="body"> 
		<template v-if="loadingState.default">
			<loading :loadingState="loadingState"></loading>
		</template>
		<template v-else>
			<template v-if="list.length>0">	
				<!-- <view class="filter-day">
					<view class="select-val">最近一个月</view>
					<view class="iconfont f-s18">&#xe642;</view>
				</view> -->
				<view class="turnover-list-wrap">
					<view class="item" v-for="(item,index) in list" :key="index">
						<view class="left-wrap">
							<view class="t split">{{item.remark}}</view>
							<view class="b">{{item.ctime}}</view>
						</view>
						<view class="right-wrap">
							<view class="t">
								<text class="f-red">+{{item.amount}}</text>
								<!-- <text v-else>-</text>100.00 -->
							</view> 
						</view>
					</view> 				
				</view>
				<loading :loadingState="loadingState"></loading>
			</template>
			<empty v-else msg="暂无相关信息"></empty>
		</template>
		
		 
	</view>
	
	<!-- 金币流水 -->
	<!-- <view v-if="token&&isLogin&&type=='gold'" class="body">
		<template v-if="!loadingState.default">				
			<view class="filter-day">
				<view class="select-val">最近一个月</view>
				<view class="iconfont f-s18">&#xe642;</view>
			</view>
			<template v-if="!score.isEmpty">
				<view class="turnover-list-wrap">
					<view class="item" v-for="(item,index) in score.data" :key="index">
						<view class="left-wrap">
							<view class="t split">{{item.content}}</view>
							<view class="b">{{item.create_at}}</view>
						</view>
						<view class="right-wrap">
							<view class="t f-red">
								<text v-if="true">+</text>
								<text v-else>-</text>{{item.score}}
							</view> 
						</view>
					</view> 				
				</view>
				<loading :loadingState="loadingState"></loading>
			</template>
			<empty v-else><view slot="text">暂无健康币记录</view></empty>
		</template>
		<template v-else>
			<loading :loadingState="loadingState"></loading>
		</template>
		 
	</view> -->
  
	
</view>
</template>

<script>
import empty from '@/components/empty.vue'
import loading from '@/components/loading-more.vue' 
export default{
	name:'invite',
	data(){
		return {
			type:'',
			isIphoneX:getApp().globalData.isIphoneX,
			isEmpty:false,
			isLogin:false,
			token:uni.getStorageSync('token'),
			loadingState:{		 
				default:true,
				loading:false,
				completed:false
			},
			list:[], 
			total:0,
			page:1
		}
	}, 
	onReachBottom(){
		if(this.loadingState.completed){ 
			this.page=1;
			return false
		}else{
			if(this.list.length<this.total&&this.list.length>0){
				this.page++; 
				this.getRedpackList(); 
			} 
		}	 
	},
	async onLoad(params) {
		this.type=params.type; 
		this.isLogin = await this.$loginState('check');
		if(this.isLogin){
			this.getRedpackList();
		} 
		
		
	},
	async onShow() { 
	},
	
	methods:{
		
		dataInit:function(){
			this.score.data=[];
			this.loadingState.default=true;
			this.loadingState.loading=false;
			this.loadingState.completed=false;
		},
		
		// 获取积分记录
		getRedpackList:async function(){
			let res=await this.$api.yfk_api.getRedpackList({
				page:this.page
			}); 
			if(res.data.ret==1){
				this.loadingState.default=false; 
				this.list=this.list.concat(res.data.data.list);
				this.total=res.data.data.count;
				if(this.list.length==res.data.data.count){
					this.loadingState.default=false;
					this.loadingState.loading=false;
					this.loadingState.completed=true;
				}else{
					this.loadingState.default=false;
					this.loadingState.loading=true;
					this.loadingState.completed=false;
				} 
			}else{
				this.loadingState.default=false; 
			} 
		} 
		
	},
	components:{
		empty, 
		loading 
	}
	
	
}
</script>

<style lang="less">  
.filter-day{
	display: flex;
	align-items: center;
	padding:30rpx;
	color:#666;
	.select-val{
		font-size: 28rpx;
	}
}
.turnover-list-wrap{ 
	background: #fff;
	margin-bottom:20rpx;
	.item{
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin:0 0 0 30rpx;
		padding:20rpx 20rpx 20rpx 0;
		border-bottom:2rpx solid #eee;
		.left-wrap{
			flex-grow: 2;
			max-width: 70%;
		}
		.right-wrap{
			text-align: right;
		}
		.t{
			margin-bottom: 10rpx;
			font-size:30rpx;
		}
		.b{
			font-size: 28rpx;
			color:#999;
		}
	}
}
 
</style>
